﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TextPioneer;

namespace TextPioneer.Facade
{
	public interface ICorporaViewDataProvider
	{
		Corpus[] Corpora { get; }
		TopicNode[] GetRootNodes(Corpus corpus);
		TopicNode[] GetChild(TopicBundle parentNode);
		IEnumerable<Keyword> GetKeywords(TopicNode node, int count);
	}

	public class CorporaViewDataProvider : ICorporaViewDataProvider
	{
		private IDataProvider dataProvider;

		public CorporaViewDataProvider(IDataProvider dataProvider)
		{
			this.dataProvider = dataProvider;
		}

		public Corpus[] Corpora
		{
			get { return dataProvider.GetCorpora(); }
		}

		public TopicNode[] GetRootNodes(Corpus corpus)
		{
			return dataProvider.GetTopLevelTopics(corpus);
		}

		public TopicNode[] GetChild(TopicBundle parentNode)
		{
			return parentNode.GetChildren();
		}

		public IEnumerable<Keyword> GetKeywords(TopicNode node, int count)
		{
			return dataProvider.GetKeywords(node, KeywordRanking.TFIDF, count);
		}
	}
}
